package ua.mykola.util;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.net.URI;

public class Files
{
    public static String readFileAsString(String filePath)
    {
        try
        {
            URI uri = ClassLoader.getSystemResource(filePath).toURI();

            File file = new File(uri);
            byte[] buffer = new byte[(int) file.length()];
            BufferedInputStream f = null;
            try
            {
                f = new BufferedInputStream(new FileInputStream(file));
                f.read(buffer);
            }
            finally
            {
                if (f != null)
                    f.close();

            }
            return new String(buffer);
        }
        catch (Exception e)
        {
            throw new RuntimeException(e);
        }
    }
}
